package com.resurvolution.kingcloudmusicspringboot.user.controller;

import com.resurvolution.kingcloudmusicspringboot.user.vo.UserVO;
import com.resurvolution.kingcloudmusicspringboot.user.service.UserService;
import com.resurvolution.kingcloudmusicspringboot.user.dto.UserDTO;
import com.resurvolution.kingcloudmusicspringboot.common.utils.UnifyResult;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    /**
     * 获取验证码
     */
    @PostMapping("/qrcode")
    public UnifyResult<String> getQRCode(@RequestBody UserDTO userDTO) {
        return UnifyResult.success(userService.getQRCode(userDTO));
    }

    /**
     * 用户登录
     */
    @PostMapping("/login")
    public UnifyResult<String> login(@RequestBody UserDTO userDTO) {
        return UnifyResult.success(userService.login(userDTO));
    }

    /**
     * 获取用户数据
     */
    @PostMapping
    public UnifyResult<UserVO> getUserDetails() {
        return UnifyResult.success(userService.getUserDetails());
    }
}
